# DAQ_SDKConfig.cmake - DAQ SDK的CMake配置文件
# 用于支持find_package(DAQ_SDK)

# 获取当前文件的路径作为SDK根目录
get_filename_component(DAQ_SDK_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(DAQ_SDK_ROOT_DIR "${DAQ_SDK_CMAKE_DIR}" ABSOLUTE)

# 引入版本配置文件
include("${DAQ_SDK_CMAKE_DIR}/DAQ_SDKVersion.cmake")

# 设置包含目录
set(DAQ_SDK_INCLUDE_DIRS "")
list(APPEND DAQ_SDK_INCLUDE_DIRS "${DAQ_SDK_ROOT_DIR}/include")
list(APPEND DAQ_SDK_INCLUDE_DIRS "${DAQ_SDK_ROOT_DIR}/include/third_party")

# 设置库目录
set(DAQ_SDK_LIBRARIES_DIR "${DAQ_SDK_ROOT_DIR}/lib")

# 根据平台设置库文件路径
if(WIN32)
  if(CMAKE_SIZEOF_VOID_P EQUAL 8)
    # 64位系统
    set(DAQ_SDK_LIBRARY_PATH "${DAQ_SDK_LIBRARIES_DIR}/windows/x64/libdaq-${DAQ_SDK_VERSION}.lib")
  else()
    # 32位系统
    set(DAQ_SDK_LIBRARY_PATH "${DAQ_SDK_LIBRARIES_DIR}/windows/x86/libdaq-${DAQ_SDK_VERSION}.lib")
  endif()
else()
  set(DAQ_SDK_LIBRARY_PATH "${DAQ_SDK_LIBRARIES_DIR}/linux/liblibdaq-${DAQ_SDK_VERSION}.so")
endif()

# 检查库文件是否存在
if(NOT EXISTS "${DAQ_SDK_LIBRARY_PATH}")
  set(DAQ_SDK_FOUND FALSE)
  if(DAQ_SDK_FIND_REQUIRED)
    message(FATAL_ERROR "DAQ SDK library not found at: ${DAQ_SDK_LIBRARY_PATH}")
  else()
    message(WARNING "DAQ SDK library not found at: ${DAQ_SDK_LIBRARY_PATH}")
  endif()
  return()
endif()

# 创建导入目标
if(NOT TARGET DAQ_SDK::libdaq)
  add_library(DAQ_SDK::libdaq UNKNOWN IMPORTED)
  set_target_properties(DAQ_SDK::libdaq PROPERTIES
    IMPORTED_LOCATION "${DAQ_SDK_LIBRARY_PATH}"
    INTERFACE_INCLUDE_DIRECTORIES "${DAQ_SDK_INCLUDE_DIRS}"
  )
endif()

# 设置传统变量（向后兼容）
set(DAQ_SDK_LIBRARIES DAQ_SDK::libdaq)
set(DAQ_SDK_DEPENDENT_LIBRARIES "${DAQ_SDK_LIBRARY_PATH}")

# 标记包已找到
set(DAQ_SDK_FOUND TRUE)

# 输出找到的信息
if(NOT DAQ_SDK_FIND_QUIETLY)
  message(STATUS "Found DAQ SDK: ${DAQ_SDK_ROOT_DIR}")
  message(STATUS "DAQ SDK version: ${DAQ_SDK_VERSION}")
  message(STATUS "DAQ SDK includes: ${DAQ_SDK_INCLUDE_DIRS}")
  message(STATUS "DAQ SDK library: ${DAQ_SDK_LIBRARY_PATH}")
endif() 